package com.wxb.note.util;

import java.util.Objects;

/**
 * @author wxb
 */
public class AssertUtil {

    public static void notNull(Object o, String msg) {
        if (Objects.isNull(o)) {
            throw new RuntimeException(String.format("%s空值", msg));
        }
    }

    public static void gtZero(Number o, String msg) {
        if (Objects.nonNull(o) && o.doubleValue() < 0.0) {
            throw new RuntimeException(String.format("%s小于0", msg));
        }
    }

    public static void geZeroAndLeOne(Number o, String msg) {
        if (Objects.nonNull(o) && o.doubleValue() < 0.0 && o.doubleValue() > 1.0) {
            throw new RuntimeException(String.format("%s不在范围内", msg));
        }
    }
}
